﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using updTest;

namespace udpclient
{
    class Program
    {
        private const int Groupport = 11000; //声明组播端口
        private static readonly IPAddress GroupAddress = IPAddress.Parse("224.100.0.1");//定义组播地址

        static async Task Main(string[] args)
        {
            //UdpClient receiveUdpClient = new UdpClient(Groupport);//建立接收端的UdpClient实例，并定义端口
            //IPEndPoint GroupEP = new IPEndPoint(GroupAddress, Groupport); //获取或设置IP地址与端口
            //receiveUdpClient.JoinMulticastGroup(GroupAddress);//加入组播组
            //receiveUdpClient.EnableBroadcast = true;//设置是否发送或接收广播数据包
            //while (true) //接收并显示消息内容
            //{
            //    byte[] receiveBytes = receiveUdpClient.Receive(ref GroupEP);
            //    string receiveMessage = Encoding.UTF8.GetString(receiveBytes, 0, receiveBytes.Length);
            //    Console.WriteLine(receiveMessage);
            //    Thread.Sleep(1000);
            //}
            // BytesIO_UDPClientService bytesIO_UDPClientService = new BytesIO_UDPClientService();
            // bytesIO_UDPClientService.CreateService();
            await  UdpMulticastReceiver.Start();
            Console.ReadLine();


        }
    }
}
